#!/bin/bash

raed -p '容器名称：' container_name
read -p '数据库root密码' -s dbrootpwd

docker exec -i $container_name mysql -uroot -p"$dbrootpwd" < talking_db.sql
docker exec -it $container_name mysql -uroot -p"$dbrootpwd" -e 'CREATE USER "trcomm"@"%" IDENTIFIED BY "yVmsW3Mjz58rmydR" PASSWORD EXPIRE NEVER;'
docker exec -it $container_name mysql -uroot -p"$dbrootpwd" -e 'GRANT SELECT,CREATE,INSERT,UPDATE,DELETE,TRIGGER,INDEX,EVENT,CREATE VIEW,SHOW VIEW,EXECUTE ON talking_db.* TO "trcomm"@"%";'